<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>注册</title>
    <meta name="keywords" content="">
    <meta name="Description" content="。">
    <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
    <meta name="format-detection" content="telephone=no">
    <meta name="format-detection" content="email=no">
    <!-- Link Swiper's CSS -->

    <link rel="stylesheet" href="${ctxPath}/assets/register/css/css.css">
    <link rel="stylesheet" href="${ctxPath}/assets/register/css/style.css">

    <script type="text/javascript" src="${ctxPath}/assets/register/js/jquery-1.8.3.min.js"></script>
    <script src="${ctxPath}/assets/register/js/jquery.form.js" type="text/javascript"></script>

</head>
<body class="pagebg">
<div class="pagebg">
    <div class="rggeusi">
        <div class="logo">
            logo
        </div>

    </div>


    <div class="zckhd">
        <div class="juzhong">
            <div class="zhucewskl">
                <form name="regform" id="regform" method="post">


                    <div class="tyhjdjs">
                        <div class="inpt_wbk  hyknms sjkjd">
                            <input type="text" name="phone" id="regmobile"
                                   onblur="if(this.value==''){this.value='请输入手机号';}"
                                   onfocus="if(this.value=='请输入手机号'){this.value='';}" value="请输入手机号"
                                   placeholder="请输入手机号" class="tykjhd_input">
                        </div>
                    </div>
                    <div class="tyhjdjs">
                        <div class="inpt_wbk  hyknms sjkjd">
                            <input type="text" name="code" id="regyzm" onblur="if(this.value==''){this.value='请输入动态码';}"
                                   onfocus="if(this.value=='请输入动态码'){this.value='';}" value="请输入动态码"
                                   placeholder="请输入动态码" class="tykjhd_input">
                            <div class="hqdtykd"><a id="regsendsmsbutton" class="huoma">获取动态码</a></div>
                        </div>

                    </div>

                    <div class="tyhjdjs">
                        <div class="inpt_wbk  hyknms sjkjd">
                            <input type="password" name="password" id="password"
                                   onblur="if(this.value==''){this.value='请输入密码';}"
                                   onfocus="if(this.value=='请输入密码'){this.value='';}" value="" placeholder="请输入密码"
                                   class="tykjhd_input">
                        </div>
                    </div>


                    <div class="tyhjdjs">
                        <div class="inpt_wbk  hyknms sjkjd">
                            <input type="password" name="password2" id="password2"
                                   onblur="if(this.value==''){this.value='请再次输入密码';}"
                                   onfocus="if(this.value=='请再次输入密码'){this.value='';}" value="" placeholder="请再次输入密码"
                                   class="tykjhd_input">
                        </div>
                    </div>

                    <div class="tyhjdjs">
                        <div class="inpt_wbk  hyknms sjkjd">
                            <input type="text" name="invitecode" id="invitecode"
                                   onblur="if(this.value==''){this.value='';}"
                                   onfocus="if(this.value==''){this.value='';}" value="" placeholder=""
                                   class="tykjhd_input" readonly>
                        </div>
                    </div>

                    <div class="zhucke">
                        <input type="submit" value="注册" class="zhcjsmd"/>
                    </div>

                    <!-- <div class="wjhkgbd">
                        已经注册账号？<a href="/Mobile/user/login" class="ljdlk">立即登录</a>
                    </div> -->

                </form>

                <div class="info">
                    <p>提示注册成功！即可进入APP 直接登录。</p>
                </div>


            </div>
        </div>
    </div>

</div>


<!-- <script>
       AOS.init({
           easing: 'ease-out-back',
           duration: 1000

       });
   </script> -->
<!--<script src="/Public/home/js/jquery-1.7.2.min.js" type="text/javascript"></script> -->
<!--<script type="text/javascript" src="/Public/home/js/tc.min.js"></script> -->
<script type="text/javascript">

    var ymzcode = "";
    var url = location.search;
    //console.log("url===="+url);
    if (url.indexOf("code") != -1) {
        var str = url.substr(1);
        //console.log(str);
        var code = str.split("=")[1];
        console.log(code);
        $('#invitecode').val(code)

    }


    $(function () {
        $('#regform').ajaxForm({
            beforeSubmit: checkregform, // 此方法主要是提交前执行的方法，根据需要设置
            success: regformcomplete, // 这是提交后的方法
            dataType: "json",
            url: "/api/ums/register"
        });

        function checkregform() {
            console.log('ymzcode', ymzcode)

            if ($.trim($('#regmobile').val()) == '' || $.trim($('#regmobile').val()) == '请输入手机号') {
                alert('请输入手机号');
                $('#regmobile').focus();
                return false;
            }
            var mobilereg = /^(((13[0-9]{1})|(14[0-9]{1})|(16[0-9]{1})|(12[0-9]{1})|(15[0-9]{1})|(17[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
            if (!mobilereg.test($('#regmobile').val())) {
                alert('请输入有效的手机号');
                $('#regmobile').focus();
                return false;
            }

            if ($.trim($('#regyzm').val()) == '' || $.trim($('#regyzm').val()) != ymzcode) {

                alert('请输入正确的动态码');
                $('#regyzm').focus();
                return false;
            }


            if ($.trim($('#password').val()) == '' || $.trim($('#password').val()) == '请输入密码') {
                alert('请输入密码');
                $('#password').focus();
                return false;
            }

            if ($.trim($('#password2').val()) == '' || $.trim($('#password2').val()) == '请输入确认密码') {
                alert('请输入确认密码');
                $('#password2').focus();
                return false;
            }
            if($.trim($('#password').val()) != $.trim($('#password2').val())){
                alert('两次输入的密码不匹配');
                $('#password2').focus();
                return false;
            }

        }

        function regformcomplete(data) {
            if (data.code == 200 || data.success == true) {
                if (data.message != '') {
                    alert(data.message);

                    setTimeout(function () {
                        window.location.href = "/member/appDownload";
                    }, 1000);

                }
                /*
                if(data.ajaxurl != '')
                {
                    setTimeout(function(){

                        //window.location.href = data.ajaxurl;

                    },1000);
                }*/
                else {
                    setTimeout(function () {
                        window.location.reload();
                    }, 1000);
                }
            }
            else {
                if (data.message != '') {
                    alert(data.message);
                }

                else {
                    setTimeout(function () {
                        window.location.reload();
                    }, 1000);
                }
            }
        }
    });

    //倒计时
    var countdown = 90;

    function settime(obj) {
        if (countdown == 0) {
            obj.text("获取验证码");
            countdown = 90;
        } else {
            obj.text("重新发送" + countdown);
            countdown--;
            setTimeout(function () {
                settime(obj)
            }, 1000)
        }
    }

    //发送验证码
    function regsendsms() {
        if ($.trim($('#regmobile').val()) == '' || $.trim($('#regmobile').val()) == '请输入手机号') {
            alert('请输入手机号');
            $('#regmobile').focus();
            return false;
        }

        var mobilereg = /^(((13[0-9]{1})|(14[0-9]{1})|(16[0-9]{1})|(12[0-9]{1})|(15[0-9]{1})|(17[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
        if (!mobilereg.test($('#regmobile').val())) {
            alert('请输入有效的手机号');
            $('#regmobile').focus();
            return false;
        }


        $.get("/api/ums/getVerifyCode", {'phone': $.trim($('#regmobile').val())},
            function (data) {
                ymzcode = "";
                if (data.code == 200) {
                    alert(data.message);
                    settime($("#regsendsmsbutton"));
                    ymzcode = data.data;
                }
                else {
                    alert(data.message);


                }
            }, "json");
    }

    $(function () {

        $("#regsendsmsbutton").click(function () {
            regsendsms();
        });


    });

</script>


</body>
</html>